package middol.test

import static java.util.Calendar.DATE

class LockTestJob {
    def lockService
    static triggers = {
//      simple repeatInterval: 5000l // execute job once in 5 seconds
        cron name:'testCronTrigger', cronExpression: '0 16 10 * * ?'
    }

    def execute() {
        // execute job
        log.info("执行0000000")
        println "执行0000000"
        def lock
        try {
            SingletonEhcacheRegionFactory
            lock = lockService.acquireLock('job_bi_updatePPM', [timeout: 1])
            if (lock) {
                println "00000000000000等待执行"
                Thread.sleep(30001)
                println("程序执行0000000000000000")
                log.info("程序执行0000000000000000")
            }else {
                println("未获取到锁000000000。。。。")
                log.info("未获取到锁0000000000000。。。。")
            }
        }catch(e){
            e.printStackTrace()
        }finally{
            lockService.releaseLock("job_bi_updatePPM", [lock: lock])
        }
    }
}
